import { API_URL } from "../constants";
import type {
  IDeviceAlarmLog,
  IDeviceOperationLog,
  IResponseList,
} from "../types";
import request from "./request";

export function getDeviceOperationLogs(
  params: {
    deviceId: number;
    pageNum: number;
    pageSize: number;
    startTime: string;
    endTime: string;
  },
  token: string,
  signal?: AbortSignal,
) {
  return request<IResponseList<{ rows: IDeviceOperationLog[] }>>(
    `${API_URL}/monitor/operlog/list`,
    {
      params: params as any,
      headers: { Authorization: token },
      signal,
    },
  );
}

export function getDeviceAlarmLogs(
  params: {
    deviceId: number;
    pageNum: number;
    pageSize: number;
    startTime: string;
    endTime: string;
  },
  token: string,
  signal?: AbortSignal,
) {
  return request<IResponseList<{ rows: IDeviceAlarmLog[] }>>(
    `${API_URL}/business/deviceStatus/alarm/query`,
    {
      method: "post",
      params: params as any,
      headers: { Authorization: token },
      signal,
    },
  );
}
